// app.js
App({
  onLaunch() {

    // wx.checkSession({
    //   success: (res) => {

    //   },
    //   fail:(err)=>{
      
    //   }
    // })
    // 展示本地存储能力
    const logs = wx.getStorageSync('logs') || []
    logs.unshift(Date.now())
    wx.setStorageSync('logs', logs)

    // 登录
    wx.login({
      success: res => {
        // 发送 res.code 到后台换取 openId, sessionKey, unionId
      }
    })
  },
  wxRequest(method, url, data, callback, errFun) {
    var that=this;
    wx.request({
      url: that.globalData.baseUrl + url,
      method: method,
      data: data,
      header: {
        'content-type':  'application/json',
        //'content-type': method == 'GET' ? 'application/json' : 'application/x-www-form-urlencoded',
        'Accept': 'application/json'
      },
      dataType: 'json',
      success: function (res) {
        callback(res.data);
      },
      fail: function (err) {
        errFun(res);
      }
    })
  },
  globalData: {
    userInfo: null,
    baseUrl:"https://shop.pin100wan.com/api/",
    thumbUrl:"https://shop.pin100wan.com"

  }
})
